# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=feroxbuster
pkgver=v2.13.0.r0.g2f608c5
pkgrel=1
epoch=1
pkgdesc='A fast, simple, recursive content discovery tool written in Rust.'
arch=('x86_64' 'aarch64')
groups=('blackarch' 'blackarch-webapp' 'blackarch-scanner' 'blackarch-fuzzer')
url='https://github.com/epi052/feroxbuster'
license=('MIT')
depends=('openssl' 'pkgconf')
makedepends=('git' 'cargo')
source=("git+https://github.com/epi052/$pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
}

build() {
  cd $pkgname

  # disable lto causing build failing
  # https://archlinux.org/todo/lto-fat-objects/
  # https://github.com/epi052/feroxbuster/blob/b44c52f0ea1fb5a3ac897ccd349e840c9d3440e9/Cargo.toml#L78
  CFLAGS+=" -ffat-lto-objects"

  cargo build --release --locked
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 755 "target/release/$pkgname" "$pkgdir/usr/bin/$pkgname"
  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  cp -a img/ "$pkgdir/usr/share/doc/$pkgname/"
  cp -a shell_completions/ ferox-config.toml.example \
    "$pkgdir/usr/share/$pkgname/"
}

